import os
import shutil


def delete_node_modules(directory):
    for root, dirs, files in os.walk(directory, topdown=False):
        for dir in dirs:
            if dir == 'node_modules' or dir == 'dist':
                node_modules_path = os.path.join(root, dir)
                try:
                    shutil.rmtree(node_modules_path)
                    print(f"已删除: {node_modules_path}")
                except Exception as e:
                    print(f"删除 {node_modules_path} 时出错: {e}")


if __name__ == "__main__":
    current_directory = os.getcwd()
    delete_node_modules(current_directory)